<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:converter="clr-namespace:Jerry.DroidBuilder.ThemeEditor.Converters"
                    xmlns:editor="clr-namespace:Jerry.DroidBuilder.ThemeEditor"
                    xmlns:local="clr-namespace:Jerry.DroidBuilder.ThemeEditor.Controls">
  <converter:AlignmentValueConverter x:Key="Local_AlignmentValueConverter" />
  <converter:DrawableValueConverter x:Key="Local_DrawableValueConverter" />

  <editor:LayoutContentTemplateSelector x:Key="Local_LayoutContentTemplateSelector" />
  <editor:DrawableContentTemplateSelector x:Key="Local_DrawableContentTemplateSelector" />

  <Style TargetType="{x:Type local:LayoutElement}">
    <!--<Setter Property="BorderBrush" Value="#FFFFFFFF" />
    <Setter Property="BorderThickness" Value="1" />-->
    <Setter Property="LayoutInfo" Value="{Binding DataContext, RelativeSource={RelativeSource Self}}" />
    <Setter Property="HorizontalAlignment">
      <Setter.Value>
        <MultiBinding Converter="{StaticResource Local_AlignmentValueConverter}" ConverterParameter="h">
          <Binding Path="layout_gravity"/>
          <Binding Path="layout_width"/>
        </MultiBinding>
      </Setter.Value>
    </Setter>
    <Setter Property="VerticalAlignment">
      <Setter.Value>
        <MultiBinding Converter="{StaticResource Local_AlignmentValueConverter}" ConverterParameter="v">
          <Binding Path="layout_gravity"/>
          <Binding Path="layout_height"/>
        </MultiBinding>
      </Setter.Value>
    </Setter>
    <!--<Setter Property="HorizontalAlignment" Value="{Binding layout_gravity, Converter={StaticResource Local_AlignmentValueConverter}, ConverterParameter=h}" />
    <Setter Property="VerticalAlignment" Value="{Binding layout_gravity, Converter={StaticResource Local_AlignmentValueConverter}, ConverterParameter=v}" />-->
    <Setter Property="HorizontalContentAlignment" Value="{Binding gravity, Converter={StaticResource Local_AlignmentValueConverter}, ConverterParameter=h}" />
    <Setter Property="VerticalContentAlignment" Value="{Binding gravity, Converter={StaticResource Local_AlignmentValueConverter}, ConverterParameter=v}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:LayoutElement}">
          <Grid>
            <ContentPresenter x:Name="m_drawableBackground"
                              Content="{Binding background, Converter={StaticResource Local_DrawableValueConverter}}"
                              ContentTemplateSelector="{StaticResource Local_DrawableContentTemplateSelector}" />
            <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
              <ContentPresenter Margin="{Binding Content.Padding, ElementName=m_drawableBackground}"
                                Content="{Binding}"
                                ContentTemplateSelector="{StaticResource Local_LayoutContentTemplateSelector}" />
            </Border>
          </Grid>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>